package testDrawD3;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import dataStructUtils.People;

public class getRelationship {
	
	public static Map<String, Object> getNeighbors(){
		
		//
		Map<String, Object> map = new HashMap<String, Object>();
		List<People> peopleList =  new ArrayList<People>();
		peopleList = initPeople();
		map.put("people", peopleList);
		
		List<Map<String, String>> src_destList = new ArrayList<Map<String,String>>();
		
		for (int i = 0; i < 10; i++) {
			Map<String, String> src_destMap = new HashMap<String, String>();
			if (i == 7) {
				src_destMap.put("src", peopleList.get(4).getName());
				src_destMap.put("dest", peopleList.get(7).getName());
				src_destList.add(src_destMap);
			} else{
				src_destMap.put("src", peopleList.get((int)(Math.random()*20)).getName());
				src_destMap.put("dest", peopleList.get((int)(Math.random()*20)).getName());
				src_destList.add(src_destMap);
			}
			
		}
		
		map.put("relation_neighbor", src_destList);
		
		
		List<Map<String, String>> src_destList2 = new ArrayList<Map<String,String>>();
		for (int i = 0; i < 7; i++) {
			Map<String, String> src_destMap = new HashMap<String, String>();
			if (i == 4) {
				src_destMap.put("src", peopleList.get(4).getName());
				src_destMap.put("dest", peopleList.get(7).getName());
				src_destList2.add(src_destMap);
			} else {
				src_destMap.put("src", peopleList.get((int)(Math.random()*20)).getName());
				src_destMap.put("dest", peopleList.get((int)(Math.random()*20)).getName());
				src_destList2.add(src_destMap);
			}
			
			
		}
		
		map.put("relation_colleague", src_destList2);
		
		
		List<Map<String, String>> src_destList3 = new ArrayList<Map<String,String>>();
		for (int i = 0; i < 8; i++) {
			Map<String, String> src_destMap = new HashMap<String, String>();
			if (i == 4) {
				src_destMap.put("src", peopleList.get(4).getName());
				src_destMap.put("dest", peopleList.get(7).getName());
				src_destList3.add(src_destMap);
			} else {
				src_destMap.put("src", peopleList.get((int)(Math.random()*20)).getName());
				src_destMap.put("dest", peopleList.get((int)(Math.random()*20)).getName());
				src_destList3.add(src_destMap);
			}
		}
		map.put("relation_relative", src_destList3);
		
		
		return map;
		
	}

	
	public static List<People> initPeople() {
		
		List<People> peopleList =  new ArrayList<People>();
		
		for (int i = 0; i < 20; i++) {
			
			People people = new People();
			
			String nameString = "Jolin" + (int)(Math.random()*100);
			people.setName(nameString);
			
			int age = 24;
			people.setAge(age);
			
			String email = "wertbdf" + (int)(Math.random()*100) + "@163.com";
			people.setEmail(email);
			
			String address = "̨" + (int)(Math.random()*100) + "";
			people.setAddress(address);
			
			String sex = (i % 2 == 0) ? "男" : "女";
			people.setSex(sex);
			
			peopleList.add(people);
			
		}
		
		return peopleList;
		
	}
	
	
	public static void main(String args[]) {
		getNeighbors();
		
	}
	
	
}



